<%@ page import="csu.web.mypetstore.domain.Item" %>
<%@ page import="java.util.List" %>
<%@ page import="csu.web.mypetstore.domain.Product" %>

<%@ include file="../common/top.jsp" %>

<div id="BackLink">
    <a href="categoryForm?categoryId=${sessionScope.category.categoryId}">Return
        to ${sessionScope.category.name}</a>
</div>

<div id="Catalog">

    <h2>${sessionScope.product.name}</h2>

    <table>
        <tr>
            <th>Item ID</th>
            <th>Product ID</th>
            <th>Attributes and Product Name</th>
            <th>List Price</th>
            <th>Action</th>
        </tr>
        <%
            List<Item> itemList = (List<Item>) session.getAttribute("itemList");
            if (itemList!= null) {
                for(Item item : itemList){
                    Product product = item.getProduct();
        %>
        <tr>
            <td>
                <a href="itemForm?itemId=<%=item.getItemId()%>">
                <%=item.getItemId()%>
                    </a>
            </td>
            <td>
                <a href="itemForm?itemId=<%=item.getItemId()%>">
                <%=product.getProductId()%>
                    </a>
            </td>
            <td>
                <%=item.getAttribute1()%>  <%=product.getName()!= null? product.getName() : "" %>
            </td>
            <td><%=item.getListPrice() %>"</td>
            <td>
                Add to Cart
            </td>
        </tr>
        <%
                }
            }
        %>
    </table>
</div>

<%@ include file="../common/bottom.jsp" %>